﻿<!DOCTYPE html>

<html>

<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
    @Scripts.Render("~/Resource/js/fe.head.js")
</head>

<body>
    <div id="app" v-cloak>
        <div class="edit_pagecontainer">
            <div class="edit_formcontainer">
                    <el-form ref="form" :model="form" :label-width="labelWidth" :rules="rules">
                            <el-row>
                                <el-col :span="24">
                                    <el-form-item label="任务名称" prop="TaskName">
                                        <el-input v-model="form.TaskName"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="24">
                                    <el-form-item label="任务类型" prop="TaskExecuteType">
                                        <el-radio v-model="form.TaskExecuteType" :label="100">循环任务</el-radio>
                                        <el-radio v-model="form.TaskExecuteType" :label="200">Corn表达式任务</el-radio>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row v-if="form.TaskExecuteType==100">
                                <el-col :span="12">
                                    <el-form-item label="执行间隔">
                                        <el-input v-model="form.TaskExecutePeriod"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="间隔单位">
                                        <template>
                                            <el-select v-model="form.TaskExecuteUnit" placeholder="请选择">
                                                <el-option v-for="item in unitList" :key="item.value" :label="item.label"
                                                    :value="item.value">
                                                </el-option>
                                            </el-select>
                                        </template>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row v-if="form.TaskExecuteType==200">
                                <el-col :span="24">
                                    <el-form-item label="Corm表达式">
                                        <el-input v-model="form.CornExplain"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="24">
                                    <el-form-item label="Job执行类" prop="JobClassName">
                                        <el-input v-model="form.JobClassName"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="12">
                                    <el-form-item label="任务状态" prop="TaskExecuteType">
                                        <el-radio v-model="form.TaskStatus" :label="1">启用</el-radio>
                                        <el-radio v-model="form.TaskStatus" :label="0">禁用</el-radio>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="任务标识" prop="TaskTag">
                                        <el-input v-model="form.TaskTag"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="24">
                                    <el-form-item label="任务说明">
                                        <el-input v-model="form.TaskExplain"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="24">
                                    <el-form-item label="排序">
                                        <el-input v-model="form.OrderNum"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                        </el-form>
            </div>
        </div>
        <div class="edit_opcontainer">
            <el-button type="primary" v-on:click="handleSubmit">保 存</el-button>
            <el-button v-on:click="close">取 消</el-button>
        </div>
    </div>
</body>
@Scripts.Render("~/Resource/js/fe.foot.js")
<script>
    var detailUrl = GetRootPath() + "Frame/Task/FindDetail";
    var updateUrl = GetRootPath() + "Frame/Task/OperateUpdate";
    var pageData = {
        //data
        form: {


        },
        rules: {
            TaskName: [{
                required: true,
                message: '请输任务名称',
                trigger: 'blur'
            }],
            TaskExecuteType: [{
                required: true,
                message: '请选择任务类型',
                trigger: 'blur'
            }],
            JobClassName: [{
                required: true,
                message: '请输入Job执行类',
                trigger: 'blur'
            }],
            TaskTag: [{
                required: true,
                message: '请输入任务标识',
                trigger: 'blur'
            }]

        },
        unitList: [{
            value: '100',
            label: '时'
        }, {
            value: '200',
            label: '分'
        }, {
            value: '300',
            label: '秒'
        }],
        //css
        labelWidth: '100px'
    };

    new Vue({
        el: '#app',
        data: pageData,
        mounted: function () {
            this.bindDetail();
        },
        methods: {
            bindDetail: function () {
                var data = {
                    RowGuid: GetUrlParam("RowGuid")
                }
                JsonAjaxPost(detailUrl, JSON.stringify(data), function (data,
                    status) {
                    if (data.code == 0) {
                        pageData.form = data.data
                    }
                })
            },
            handleSubmit: function () {
                this.$refs["form"].validate((valid) => {
                    if (valid) {
                        JsonAjaxPost(updateUrl, JSON.stringify(pageData.form), function (data,
                            status) {
                            if (data.code == 0) {
                                OpenSuccess('提示', '保存成功！', function () {
                                    CloseDialog();
                                })
                            } else {
                                OpenFail('提示', data.msg)
                            }
                        })
                    }
                });
            },
            close: function () {
                CloseDialog();
            },

        }
    })
</script>

</html>
